package com.awan.utils;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.ProgressBar;

import com.beem.project.beem.R;
import com.beem.project.beem.ui.ContactList;

public class GeneralStatic {
	
	public static SpannableStringBuilder getEmoDrawId(String sChar, Resources res){
		SpannableStringBuilder ssb = new SpannableStringBuilder( sChar );
		if(sChar.trim().contains(":)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.happy );
			ssb = attachImage(ssb, sChar, ":)", emoticon);
		}
		if(sChar.trim().contains(":(")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.sad );
			ssb = attachImage(ssb, sChar, ":(", emoticon);
		}
		if(sChar.trim().contains(";)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.winking );
			ssb = attachImage(ssb, sChar, ";)", emoticon);
		}
		if(sChar.trim().contains(":D")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.biggrin );
			ssb = attachImage(ssb, sChar, ":D", emoticon);
		}
		if(sChar.trim().contains(";;)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.battingeyelashes );
			ssb = attachImage(ssb, sChar, ";;)", emoticon);
		}
		if(sChar.trim().contains(":-/")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.confused );
			ssb = attachImage(ssb, sChar, ":-/", emoticon);
		}
		if(sChar.trim().contains(":x")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.lovestruck );
			ssb = attachImage(ssb, sChar, ":x", emoticon);
		}
		if(sChar.trim().contains(":\">")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.blushing );
			ssb = attachImage(ssb, sChar, ":\">", emoticon);
		}
		if(sChar.trim().contains(":p")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.tounge );
			ssb = attachImage(ssb, sChar, ":p", emoticon);
		}
		if(sChar.trim().contains(":*")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.kiss );
			ssb = attachImage(ssb, sChar, ":*", emoticon);
		}
		if(sChar.trim().contains(":O")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.surpized );
			ssb = attachImage(ssb, sChar, ":O", emoticon);
		}
		if(sChar.trim().contains("X(")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.angry );
			ssb = attachImage(ssb, sChar, "X(", emoticon);
		}
		if(sChar.trim().contains(":>")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.smug );
			ssb = attachImage(ssb, sChar, ":>", emoticon);
		}
		if(sChar.trim().contains("B-)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.cool );
			ssb = attachImage(ssb, sChar, "B-)", emoticon);
		}
		if(sChar.trim().contains(":-s")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.worried );
			ssb = attachImage(ssb, sChar, ":-s", emoticon);
		}
		if(sChar.trim().contains(">:)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.devil );
			ssb = attachImage(ssb, sChar, ">:)", emoticon);
		}
		if(sChar.trim().contains(":((")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.crying );
			ssb = attachImage(ssb, sChar, ":((", emoticon);
		}
		if(sChar.trim().contains(":))")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.laughing );
			ssb = attachImage(ssb, sChar, ":))", emoticon);
		}
		if(sChar.trim().contains(":|")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.straightface );
			ssb = attachImage(ssb, sChar, ":|", emoticon);
		}
		if(sChar.trim().contains("/:)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.raisedeyebrows );
			ssb = attachImage(ssb, sChar, "/:)", emoticon);
		}
		if(sChar.trim().contains("0:-)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.angel );
			ssb = attachImage(ssb, sChar, "0:-)", emoticon);
		}
		if(sChar.trim().contains(":-B")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.nerd );
			ssb = attachImage(ssb, sChar, ":-B", emoticon);
		}
		if(sChar.trim().contains("=;")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.talktothehand );
			ssb = attachImage(ssb, sChar, "=;", emoticon);
		}
		if(sChar.trim().contains("I-)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.sleepy );
			ssb = attachImage(ssb, sChar, "I-)", emoticon);
		}
		if(sChar.trim().contains("8-|")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.rollingeyes );
			ssb = attachImage(ssb, sChar, "8-|", emoticon);
		}
		if(sChar.trim().contains(":-&")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.sick );
			ssb = attachImage(ssb, sChar, ":-&", emoticon);
		}
		if(sChar.trim().contains(":-$")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.donttellanyone );
			ssb = attachImage(ssb, sChar, ":-$", emoticon);
		}
		if(sChar.trim().contains("[-(")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.notalking );
			ssb = attachImage(ssb, sChar, "[-(", emoticon);
		}
		if(sChar.trim().contains(":o)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.clown );
			ssb = attachImage(ssb, sChar, ":o)", emoticon);
		}
		if(sChar.trim().contains("8-}")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.silly );
			ssb = attachImage(ssb, sChar, "8-}", emoticon);
		}
		if(sChar.trim().contains("(:|")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.yawn );
			ssb = attachImage(ssb, sChar, "(:|", emoticon);
		}
		if(sChar.trim().contains("=P~")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.drooling );
			ssb = attachImage(ssb, sChar, "=P~", emoticon);
		}
		if(sChar.trim().contains(":-?")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.thinking );
			ssb = attachImage(ssb, sChar, ":-?", emoticon);
		}
		if(sChar.trim().contains("#-o")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.doh );
			ssb = attachImage(ssb, sChar, "#-o", emoticon);
		}
		if(sChar.trim().contains("=D>")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.applause );
			ssb = attachImage(ssb, sChar, "=D>", emoticon);
		}
		if(sChar.trim().contains(":@)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.pig );
			ssb = attachImage(ssb, sChar, ":@)", emoticon);
		}
		if(sChar.trim().contains("3:-O")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.cow );
			ssb = attachImage(ssb, sChar, "3:-O", emoticon);
		}
		if(sChar.trim().contains(":(|)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.monkey );
			ssb = attachImage(ssb, sChar, ":(|)", emoticon);
		}
		if(sChar.trim().contains("~:>")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.chicken );
			ssb = attachImage(ssb, sChar, "~:>", emoticon);
		}
		if(sChar.trim().contains("@};-")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.rose );
			ssb = attachImage(ssb, sChar, "@};-", emoticon);
		}
		if(sChar.trim().contains("%%-")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.goodluck );
			ssb = attachImage(ssb, sChar, "%%-", emoticon);
		}
		if(sChar.trim().contains("**==")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.flag );
			ssb = attachImage(ssb, sChar, "**==", emoticon);
		}
		if(sChar.trim().contains("(~~)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.pumpkin );
			ssb = attachImage(ssb, sChar, "(~~)", emoticon);
		}
		if(sChar.trim().contains("~o)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.coffee );
			ssb = attachImage(ssb, sChar, "~o)", emoticon);
		}
		if(sChar.trim().contains("*-:)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.idea );
			ssb = attachImage(ssb, sChar, "*-:)", emoticon);
		}
		if(sChar.trim().contains("8-X")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.skull );
			ssb = attachImage(ssb, sChar, "8-X", emoticon);
		}
		if(sChar.trim().contains("=:)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.bug );
			ssb = attachImage(ssb, sChar, "=:)", emoticon);
		}
		if(sChar.trim().contains(">-)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.alien );
			ssb = attachImage(ssb, sChar, ">-)", emoticon);
		}
		if(sChar.trim().contains(":-L")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.frustrated );
			ssb = attachImage(ssb, sChar, ":-L", emoticon);
		}
		if(sChar.trim().contains("<):)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.cowboy );
			ssb = attachImage(ssb, sChar, "<):)", emoticon);
		}
		if(sChar.trim().contains("[-o<")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.praying );
			ssb = attachImage(ssb, sChar, "[-o<", emoticon);
		}
		if(sChar.trim().contains("@-)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.hypnotised );
			ssb = attachImage(ssb, sChar, "@-)", emoticon);
		}
		if(sChar.trim().contains("$-)")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.moneyeyes );
			ssb = attachImage(ssb, sChar, "$-)", emoticon);
		}
		if(sChar.trim().contains(":-\"")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.whistling );
			ssb = attachImage(ssb, sChar, ":-\"", emoticon);
		}
		if(sChar.trim().contains(":^o")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.liar );
			ssb = attachImage(ssb, sChar, ":^o", emoticon);
		}
		if(sChar.trim().contains("b-(")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.punch );
			ssb = attachImage(ssb, sChar, "b-(", emoticon);
		}
		if(sChar.trim().contains(":)>-")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.peacesign );
			ssb = attachImage(ssb, sChar, ":)>-", emoticon);
		}
		if(sChar.trim().contains("[-X")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.shameonyou );
			ssb = attachImage(ssb, sChar, "[-X", emoticon);
		}
		if(sChar.trim().contains("\\:D/")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.dancing );
			ssb = attachImage(ssb, sChar, "\\:D/", emoticon);
		}
		if(sChar.trim().contains(">:D<")){
			Bitmap emoticon = BitmapFactory.decodeResource( res, R.drawable.bighug );
			ssb = attachImage(ssb, sChar, ">:D<", emoticon);
		}
		return ssb;
	}
	private static SpannableStringBuilder attachImage(SpannableStringBuilder ssb, String fullChar, String findChar, Bitmap smiley){
		String[] splitChar = fullChar.split(" ");
		if(splitChar.length >0){
			for(int x=0; x<splitChar.length; x++){
				String tmpStringAt = splitChar[x];
    			int findCharAtIndex = tmpStringAt.indexOf(findChar);
    			if(findCharAtIndex!=-1){
    				String tmpStringDorongan = "";
    				int startLength = 0;
    				if(x>0){
	    				for(int y=0; y<x; y++){
	    					tmpStringDorongan = tmpStringDorongan+" "+splitChar[y];
	    				}
    				}    				
    				startLength = tmpStringDorongan.length();
    				ssb.setSpan( new ImageSpan( smiley ), startLength, (startLength+findChar.length()), Spannable.SPAN_INCLUSIVE_INCLUSIVE );
    			}
			}
		}
		return ssb;
	}
	public static String switchEmoIdToChar(int id){
		
		String result = null;
		
		if(id==R.drawable.happy){result=":)";}
		if(id==R.drawable.sad){result=":(";}
		if(id==R.drawable.winking){result=";)";}
		if(id==R.drawable.biggrin){result=":D";}
		if(id==R.drawable.battingeyelashes){result=";;)";}
		if(id==R.drawable.confused){result=":-/";}
		if(id==R.drawable.lovestruck){result=":x";}
		if(id==R.drawable.blushing){result=":\">";}
		if(id==R.drawable.tounge){result=":p";}
		if(id==R.drawable.kiss){result=":*";}
		
		if(id==R.drawable.surpized){result=":O";}
		if(id==R.drawable.angry){result="X(";}
		if(id==R.drawable.smug){result=":>";}
		if(id==R.drawable.cool){result="B-)";}
		if(id==R.drawable.worried){result=":-s";}
		if(id==R.drawable.devil){result=">:)";}
		if(id==R.drawable.crying){result=":((";}
		if(id==R.drawable.laughing){result=":))";}
		if(id==R.drawable.straightface){result=":|";}
		if(id==R.drawable.raisedeyebrows){result="/:)";}
		
		if(id==R.drawable.angel){result="0:-)";}
		if(id==R.drawable.nerd){result=":-B";}
		if(id==R.drawable.talktothehand){result="=;";}
		if(id==R.drawable.sleepy){result="|-)";}
		if(id==R.drawable.rollingeyes){result="8-|";}
		if(id==R.drawable.sick){result=":-&";}
		if(id==R.drawable.donttellanyone){result=":-$";}
		if(id==R.drawable.notalking){result="[-(";}
		if(id==R.drawable.clown){result=":o)";}
		if(id==R.drawable.silly){result="8-}";}
		
		if(id==R.drawable.yawn){result="(:|";}
		if(id==R.drawable.drooling){result="=P~";}
		if(id==R.drawable.thinking){result=":-?";}
		if(id==R.drawable.doh){result="#-o";}
		if(id==R.drawable.applause){result="=D>";}
		if(id==R.drawable.pig){result=":@)";}
		if(id==R.drawable.cow){result="3:-O";}
		if(id==R.drawable.monkey){result=":(|)";}
		if(id==R.drawable.chicken){result="~:>";}
		if(id==R.drawable.rose){result="@};-";}
		
		if(id==R.drawable.goodluck){result="%%-";}
		if(id==R.drawable.flag){result="**==";}
		if(id==R.drawable.pumpkin){result="(~~)";}
		if(id==R.drawable.coffee){result="~o)";}
		if(id==R.drawable.idea){result="*-:)";}
		if(id==R.drawable.skull){result="8-X";}
		if(id==R.drawable.bug){result="=:)";}
		if(id==R.drawable.alien){result=">-)";}
		if(id==R.drawable.frustrated){result=":-L";}
		if(id==R.drawable.cowboy){result="<):)";}
		
		if(id==R.drawable.praying){result="[-o<";}
		if(id==R.drawable.hypnotised){result="@-)";}
		if(id==R.drawable.moneyeyes){result="$-)";}
		if(id==R.drawable.whistling){result=":-\"";}
		if(id==R.drawable.liar){result=":^o";}
		if(id==R.drawable.punch){result="b-(";}
		if(id==R.drawable.peacesign){result=":)>-";}
		if(id==R.drawable.shameonyou){result="[-X";}
		if(id==R.drawable.dancing){result="\\:D/";}
		if(id==R.drawable.bighug){result=">:D<";}
    	
		return result;
		
	}
	public static Dialog getDialogProgress(Context context){
		Dialog dialog = new Dialog(context);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.setContentView(R.layout.loading_dialog);
		return dialog;
	}
	
}
